home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
compugr.zip
/
SUBGRAPH.INC
< prev
Wrap
Text File
|
1992-08-20
|
1KB
|
45 lines
function achievable( var graph : sectorArray;
start : sector;
var subgr : sectorSet ) : sectorindex;
{ compute connected subgraph leaving start; return number of adjacent
sectors as value of function }
var
si : sectorIndex;
wi : invIndex;
breadth : queue;
s,
daddy, sonny : sector;
count : sectorindex;
i : warpindex;
d : distanceArray;
begin
for s := 1 to maxSector do
begin
D[s].d := -1;
subgr[ s ] := false;
end; {for}
breadth.front := 0;
enqueue( breadth, start, start );
subgr[start] := true;
while breadth.front > 0 do
begin
serve( breadth, daddy, sonny );
if D[ sonny ].d = -1 then {haven't hit him before:}
begin
D[ sonny ].d := D[ daddy ].d + 1;
D[ sonny ].s := daddy;
with graph[ sonny ] do if number > 0 then
if (graph[sonny].etc and avoid) = Nothing then
for wi := 1 to number do
if not subgr[ data[wi] ] then
begin
enqueue( breadth, sonny, data[ wi ] );
subgr[ data[wi] ] := true;
end; {if with for if}
end; {if}
end; {while}
count := 0;
for s := 1 to maxSector do if subgr[s] then inc( count );
achievable := count;
end;